package com.xzkydz.all_sensor.fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.xzkydz.all_sensor.activity.MainActivity;
import com.xzkydz.all_sensor.allsensor.R;

/**
 * Created by Smilekun on 2016/8/26.
 */
public class SpeedFragment extends Fragment {
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View  view  =  inflater.inflate(R.layout.fragment_speed, container, false);
        final MainActivity mActivity  = (MainActivity)getActivity();
        final EditText  mEditText  = (EditText)view.findViewById(R.id.et_banjing);
        Button  mButton  =  (Button)view.findViewById(R.id.btn_banjing);
        mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mEditText.getText().toString().length()==0){
                    Toast.makeText(mActivity,"请输入半径！" ,Toast.LENGTH_SHORT).show();
                }else{
                    float val  =  Float.parseFloat(mEditText.getText().toString());
                    mActivity.radiou= val;
                    Toast.makeText(mActivity,"半径值为："+val,Toast.LENGTH_SHORT).show();
                }

            }
        });



        return  view ;
    }
}
